function getCode() {
    var weChatUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx92c338b093b87079&redirect_uri=' + encodeURIComponent("http://static.vote.ukebms.com/wechat/code") + '&response_type=code&scope=snsapi_userinfo&state=' + localStorage.getItem("articleId") + '#wechat_redirect';
    location.href = weChatUrl;
}

function getopenid() {
    var code = sessionStorage.getItem("code");
    var accessToken = sessionStorage.getItem("access_token");
    var openid = sessionStorage.getItem("openid");
    if (isNull(accessToken) === true){
        var xhr = new XMLHttpRequest();
        xhr.open("GET", "http://static.vote.ukebms.com/wechat/getOpenId?code=" + code + "", false);
        xhr.send(null);
        var t = JSON.parse(xhr.responseText);
        var c = JSON.parse(t);
        if (isNull(c.errcode) !== true){
            getCode();
            return;
        }
        sessionStorage.setItem("access_token",c.access_token);
        sessionStorage.setItem("openid",c.openid);
        accessToken = c.access_token;
        openid = c.openid;
    }
    var xhr1 = new XMLHttpRequest();
    xhr1.open("GET", "http://static.vote.ukebms.com/wechat/getUser?accessToken=" + accessToken + "&openid=" + openid + "", false);
    xhr1.send(null);
    var a = JSON.parse(xhr1.responseText);
    var b = JSON.parse(a);
    var xhr2 = new XMLHttpRequest();
    xhr2.open("GET", "http://static.vote.ukebms.com/wechat/upload?path=" + encodeURIComponent(b.headimgurl) + "", false);
    xhr2.send(null);
    var aa = JSON.parse(xhr2.responseText);
    var bb = JSON.parse(aa);
    var d = TloginU("1", b.openid, b.nickname, bb.response.body.uploadFilesResult[0].newFilename, b.sex);
    return d;
}